package com.example.test.chapter9.tabwidget;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TabHost;

import com.example.test.R;
import com.example.test.chapter9.MainChapter9;

public class TabWidget extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tabwidget);
		TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
		tabHost.setup();

		TabHost.TabSpec spec = tabHost.newTabSpec("tabscontent1");
		spec.setContent(R.id.tabscontent1);
		spec.setIndicator("Analock clock");
		tabHost.addTab(spec);

		spec = tabHost.newTabSpec("tabscontent2");
		spec.setContent(R.id.tabscontent2);
		spec.setIndicator("Digital clock");
		tabHost.addTab(spec);

		spec = tabHost.newTabSpec("tabscontent3");
		spec.setContent(R.id.tabscontent3);
		spec.setIndicator("Button");
		tabHost.addTab(spec);

		tabHost.setCurrentTabByTag("tabscontent2");
		Button btn = (Button) findViewById(R.id.backpage);
		btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getApplicationContext(),
						MainChapter9.class);
				startActivity(intent);
				finish();
			}
		});
	}
}
